do
  function setType(parent)
    parent:setType("gunner");
  end
  
  
  function update(parent)
    
    local brave = parent:getBravery();
    local enemies = 0;
    local comrades = 0;
    
    local itr = parent:getComrades():iterator();
    while itr:hasNext() do
      local element = itr:next();
      comrades = comrades + 1;
    end
    
    local itr2 = parent:getEnemies():iterator();
    while itr2:hasNext() do
      local element = itr2:next();
      enemies = enemies + 1;
    end
    
    local danger = comrades-enemies;
    if danger < 1 then
      danger = 1;
    end
    
    if enemies > 0 then
      local itr3 = parent:getEnemies():iterator();
      local element = itr3:next();
      parent:attack(element,brave*danger);
    end
  
  end
  
  
  
  setType();
  update();
end